<?php
namespace app\index\controller;

use think\App;
use app\index\controller\IndexBaseController;
use think\facade\View;
use app\common\model\JfArticle as JfArticleModel;

class Index extends IndexBaseController {

  protected $jf_article_model;
  public function __construct(App $app)
  {
      parent::__construct($app);
      $this->jf_article_model = new JfArticleModel();
  }

  public function index()
  {
    $data = [
      'pageIndex' => 1,
      'pageRow' => 10
    ];
    $articles = $this->jf_article_model->getNormalJfArticleList($data);
    foreach ($articles['list'] as $article) {
      $article['user'] = $this->jf_article_model->user()->where('status', 1)->find($article['user_id']);
    }
    View::assign('articles', $articles['list']);
    return View::fetch('index');
  }
}
